package com.example.vueblog.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.api.R;
import com.example.vueblog.common.Result;
import com.example.vueblog.entity.UserInfo;
import com.example.vueblog.entity.security.LoginBody;
import com.example.vueblog.service.impl.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 登录相关接口
 *
 * @author yushunshun
 * @date 2022/7/18 23:46
 */
@RestController
@Slf4j
public class LoginController {
    @Autowired
    LoginService loginService;

    /**
     * 登录
     *
     * @param loginBody
     * @return
     */
    @PostMapping("/login")
    public Result<UserInfo> login(@RequestBody @Valid LoginBody loginBody) {
        UserInfo userInfo = loginService.login(loginBody);
        return Result.ok(userInfo);
    }



}
